package broadcastreceiver.demo;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class SMSReceiver extends BroadcastReceiver{

	 public SMSReceiver() {  
	        Log.v("SMSReceiver", "SMSReceiver()");  
	 }  
	 
	@Override
	public void onReceive(Context context, Intent intent) {
		
		Log.v("SMSReceiver", "onReceive");
		
		Bundle bundle = intent.getExtras();
		Object[] objArray = (Object[])bundle.get("pdus");
		
		SmsMessage[] smsMessage = new SmsMessage[objArray.length];
		
		for (int i = 0; i < objArray.length; i++) {
			smsMessage[i] = SmsMessage.createFromPdu((byte[])objArray[i]);
			Log.v("SMSReceiver", smsMessage[i].getDisplayMessageBody());
		}
	}
	
}
